package com.booking.mainService.service.impl;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.booking.login.pojo.User;
import com.booking.mainService.actions.BookingAction;
import com.booking.mainService.dao.MainDao;
import com.booking.mainService.pojo.Airport;
import com.booking.mainService.pojo.Flight;
import com.booking.mainService.pojo.UserTicket;
import com.booking.mainService.service.MainService;

// TODO: Auto-generated Javadoc
/**
 * The Class MainServiceImpl.
 * 
 * @author coco
 * @version 1.0
 */
public class MainServiceImpl implements MainService {

	/** The main dao impl. */
	private MainDao mainDaoImpl;
	
	/** The user type map. */
	private Map userTypeMap = new HashMap(3);
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see com.booking.mainService.service.MainService#queryFlightList()
	 */
	public List queryFlightList() throws RuntimeException {
		// TODO Auto-generated method stub
		return this.mainDaoImpl.queryFlightList();
	}

	/**
	 * Gets the main dao impl.
	 * 
	 * @return the mainDaoImpl
	 */
	public MainDao getMainDaoImpl() {
		return mainDaoImpl;
	}

	/**
	 * Sets the main dao impl.
	 * 
	 * @param mainDaoImpl the mainDaoImpl to set
	 */
	public void setMainDaoImpl(MainDao mainDaoImpl) {
		this.mainDaoImpl = mainDaoImpl;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.booking.mainService.service.MainService#queryFlightById(int)
	 */
	public Flight queryFlightById(int id) throws RuntimeException {
		// TODO Auto-generated method stub
		return this.mainDaoImpl.queryFlightById(id);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.booking.mainService.service.MainService#deleteFlightById(int)
	 */
	public void deleteFlightById(int id) throws RuntimeException {
		// TODO Auto-generated method stub
		this.mainDaoImpl.deleteFlightById(id);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.booking.mainService.service.MainService#insertFlight(com.booking.
	 * mainService.pojo.Flight)
	 */
	public void insertFlight(Flight flight) throws RuntimeException {
		// TODO Auto-generated method stub
		this.mainDaoImpl.insertFlight(flight);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.booking.mainService.service.MainService#updateFlightById(com.booking
	 * .mainService.pojo.Flight)
	 */
	public void updateFlightById(Flight flight) throws RuntimeException {
		// TODO Auto-generated method stub
		this.mainDaoImpl.updateFlightById(flight);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.booking.mainService.service.MainService#batchDelete(java.lang.String,
	 * java.lang.Object[])
	 */
	public void batchDelete(String statementName, Object[] o)
			throws RuntimeException {
		// TODO Auto-generated method stub
		this.mainDaoImpl.batchDelete(statementName, o);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.booking.mainService.service.MainService#deleteFlights(java.lang.String
	 * [])
	 */
	public void deleteFlights(String[] id) throws RuntimeException {
		// TODO Auto-generated method stub
		this.mainDaoImpl.deleteFlights(id);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.booking.mainService.service.MainService#queryFlightList(com.booking
	 * .mainService.pojo.Flight)
	 */
	public List queryFlightList(Flight flight) throws RuntimeException {
		// TODO Auto-generated method stub
		return this.mainDaoImpl.queryFlightList(flight);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.booking.mainService.service.MainService#bookingUserTicket(com.booking
	 * .mainService.pojo.UserTicket)
	 */
	public String bookingUserTicket(UserTicket userTicket)
			throws RuntimeException {
		String str = null;
		try {
			this.booking(userTicket);
		} catch (Exception e) {
			e.printStackTrace();
			str = e.getMessage();
		}
		return str;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.booking.mainService.service.MainService#booking(com.booking.mainService
	 * .pojo.UserTicket)
	 */
	public void booking(UserTicket userTicket) throws RuntimeException{
		// TODO Auto-generated method stub
		this.mainDaoImpl.booking(userTicket);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.booking.mainService.service.MainService#queryUserTicketListByFlightId
	 * (int)
	 */
	public List queryUserTicketListByFlightId(int id) throws RuntimeException {
		// TODO Auto-generated method stub
		return this.mainDaoImpl.queryUserTicketListByFlightId(id);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.booking.mainService.service.MainService#queryUserTicketListByUserId
	 * (int)
	 */
	public List queryUserTicketListByUserId(int id) throws RuntimeException {
		// TODO Auto-generated method stub
		return this.mainDaoImpl.queryUserTicketListByUserId(id);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.booking.mainService.service.MainService#deleteUserTicketById(com.
	 * booking.mainService.pojo.UserTicket)
	 */
	public void deleteUserTicketById(UserTicket userTicket)
			throws RuntimeException {
		// TODO Auto-generated method stub
		this.mainDaoImpl.deleteUserTicketById(userTicket);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.booking.mainService.service.MainService#queryUserTicketById(int)
	 */
	public UserTicket queryUserTicketById(int id) throws RuntimeException {
		// TODO Auto-generated method stub
		return this.mainDaoImpl.queryUserTicketById(id);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.booking.mainService.service.MainService#queryUserList()
	 */
	public List queryUserList() throws RuntimeException {
		// TODO Auto-generated method stub
		return this.mainDaoImpl.queryUserList();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.booking.mainService.service.MainService#queryUserById(int)
	 */
	public User queryUserById(int id) throws RuntimeException {
		// TODO Auto-generated method stub
		return this.mainDaoImpl.queryUserById(id);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.booking.mainService.service.MainService#deleteUserById(int)
	 */
	public void deleteUserById(int id) throws RuntimeException {
		// TODO Auto-generated method stub
		this.mainDaoImpl.deleteUserById(id);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @seecom.booking.mainService.service.MainService#insertUser(com.booking.
	 * mainService.pojo.User)
	 */
	public void insertUser(User user) throws RuntimeException {
		// TODO Auto-generated method stub
		this.mainDaoImpl.insertUser(user);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.booking.mainService.service.MainService#updateUserById(com.booking
	 * .mainService.pojo.User)
	 */
	public void updateUserById(User user) throws RuntimeException {
		// TODO Auto-generated method stub
		this.mainDaoImpl.updateUserById(user);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.booking.mainService.service.MainService#deleteUsers(java.lang.String
	 * [])
	 */
	public void deleteUsers(String[] id) throws RuntimeException {
		// TODO Auto-generated method stub
		this.mainDaoImpl.deleteUsers(id);
	}

	/* (non-Javadoc)
	 * @see com.booking.mainService.service.MainService#deleteAirportById(int)
	 */
	public void deleteAirportById(int id) throws RuntimeException {
		// TODO Auto-generated method stub
		this.mainDaoImpl.deleteAirportById(id);
	}

	/* (non-Javadoc)
	 * @see com.booking.mainService.service.MainService#deleteAirports(java.lang.String[])
	 */
	public void deleteAirports(String[] id) throws RuntimeException {
		// TODO Auto-generated method stub
		this.mainDaoImpl.deleteAirports(id);
	}

	/* (non-Javadoc)
	 * @see com.booking.mainService.service.MainService#insertAirport(com.booking.mainService.pojo.Airport)
	 */
	public void insertAirport(Airport airport) throws RuntimeException {
		// TODO Auto-generated method stub
		this.mainDaoImpl.insertAirport(airport);
	}

	/* (non-Javadoc)
	 * @see com.booking.mainService.service.MainService#queryAirportById(int)
	 */
	public Airport queryAirportById(int id) throws RuntimeException {
		// TODO Auto-generated method stub
		return this.mainDaoImpl.queryAirportById(id);
	}

	/* (non-Javadoc)
	 * @see com.booking.mainService.service.MainService#queryAirportList()
	 */
	public List queryAirportList() throws RuntimeException {
		// TODO Auto-generated method stub
		return this.mainDaoImpl.queryAirportList();
	}

	/* (non-Javadoc)
	 * @see com.booking.mainService.service.MainService#updateAirportById(com.booking.mainService.pojo.Airport)
	 */
	public void updateAirportById(Airport airport) throws RuntimeException {
		// TODO Auto-generated method stub
		this.mainDaoImpl.updateAirportById(airport);
	}

	/* (non-Javadoc)
	 * @see com.booking.mainService.service.MainService#queryUserTypeMap()
	 */
	public Map queryUserTypeMap() throws RuntimeException {
		// TODO Auto-generated method stub
		if(userTypeMap.size()==0){
			userTypeMap.put(1, "member");
			userTypeMap.put(2, "manager");
			userTypeMap.put(3, "administrator");
		}
		return userTypeMap;
	}

	/* (non-Javadoc)
	 * @see com.booking.mainService.service.MainService#queryFlightDate(com.booking.mainService.pojo.Flight)
	 */
	public Flight queryFlightDate(Flight flight) throws RuntimeException {
		// TODO Auto-generated method stub
		return this.mainDaoImpl.queryFlightDate(flight);
	}

}
